package com.draby.fantasy.main;

import com.draby.fantasy.dataTypes.Map;
import com.draby.fantasy.exceptions.ParamsLengthNotMatchException;
import com.draby.fantasy.factories.CircleMapFactory;
import com.draby.fantasy.factories.IMapFactory;
import com.draby.fantasy.factories.RectangleMapFactory;
import com.draby.fantasy.methods.IGenerateMap;
import com.draby.fantasy.methods.IGenerateMaze;
import com.draby.fantasy.methods.map.NoneObstacleMap;
import com.draby.fantasy.methods.maze.DigWallMaze;

public class Main {
    // 阶段1：生成迷宫地图
    // 阶段2：进行游戏(本版本暂不考虑)
    public static void main(String[] args) {
        // 用于判断是否可以开始下一阶段(生成迷宫阶段完成)
        boolean mapSuccess = false;
        boolean mazeSuccess = false;
        // 创建地图工厂来创建地图
        IMapFactory mapFactory = new RectangleMapFactory();
//        IMapFactory mapFactory = new CircleMapFactory();
        Map map = mapFactory.createMap();
        while (!(mapSuccess && mazeSuccess)){
            // 创建生成地图的方法来生成地图
            IGenerateMap generateMap = new NoneObstacleMap();
            try {
                mapSuccess = generateMap.generateMap(map);
            } catch (ParamsLengthNotMatchException e) {
                // 处理该异常，当前版本无需做处理，大概
                e.printStackTrace();
            }
            // 创建生成迷宫的方法来生成迷宫
            IGenerateMaze generateMaze = new DigWallMaze();
            mazeSuccess = generateMaze.generateMaze(map);
        }
        System.out.println("完成\n\n" + map);
    }
}
